﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Scripting.Ast;

namespace Scala.Compiler.Ast
{
    public class IfStatement:Statement
    {
        private readonly Expression _cond;
        private readonly Statement _thenp;
        private readonly Statement _elsep;

        public IfStatement(Expression cond, Statement thenp, Statement elsep)
        {
            _cond = cond;
            _thenp = thenp;
            _elsep = elsep;
        }

        public Expression Cond
        {
            get { return _cond; }
        }

        public Statement Thenp
        {
            get { return _thenp; }
        }

        public Statement Elsep { get { return _elsep; } }

        public override void Walk(ScalaWalker walker)
        {
            if (walker.Walk(this))
            {
                if (_thenp != null)
                {
                    _thenp.Walk(walker);
                }
                if (_elsep != null)
                {
                    _elsep.Walk(walker);
                }
            }
            walker.PostWalk(this);
        }

        public override Microsoft.Scripting.Ast.Expression Reduce()
        {
            throw new NotImplementedException();
        }
    }
}
